#include<iostream>
#include<cstdio>
#include<signal.h>
#include<unistd.h>

int quit = 0;

void handler(int signo)
{
    std::cout << "捕捉到一个信号:" << signo << std::endl;
    std::cout << "把quit改为1，然后退出" << std::endl;

    std::cout << "quit : " << quit << "->";
    quit = 1;
    std::cout << quit << std::endl;

}


int main()
{
    struct sigaction ibect,obect;
    ibect.sa_flags  = 0;
    ibect.sa_handler = &handler;
    
    // 调用ibect选项去解决
    sigaction(2,&ibect,&obect);
    while(!quit) sleep(1);
 
    return 0;
}